 <template>
 	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="tiny">
 		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
		 <div class="bt">修改</div>
 		<el-form label-width="100px" class="form">
 			<el-form-item label="班级名称">
 				<!-- <el-input v-model="form.bjid"  placeholder="请输入" class="select-block"></el-input> -->
        <el-select v-model="form.bjmc"  class="select-block">
					<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select>
 			</el-form-item>
 			<el-form-item label="类型">
 				<!-- <el-input v-model="form.lxmc"  placeholder="请输入" class="select-block"></el-input> -->
        <el-select v-model="form.lxmc" class="select-block">
				 <el-option label="老师" value="t"></el-option>
					 <el-option label="学生" value="s"></el-option>
			 </el-select>
 			</el-form-item>
 			<el-form-item label="通知主题">
 				<el-input v-model="form.bt" type="textarea" :rows="2" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="消息来源">
 				<!-- <el-input v-model="form.noticesourcemc"  placeholder="请输入" class="select-block"></el-input> -->
        <el-select v-model="form.noticesourcemc" placeholder="请选择消息来源" class="select-block">
         <el-option label="后台发送" value="a"></el-option>
           <el-option label="前台发送" value="b"></el-option>
       </el-select>
 			</el-form-item>
 			<el-form-item label="通知内容">
 				<el-input v-model="form.nr" type="textarea" :rows="4" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<!--<el-form-item label="序号">
 				<el-input v-model="form.xh"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item> -->
 		</el-form>
 		<el-button type="info" class="submit" @click="submit">修改</el-button>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 				form: {
					 bt :'',
					 nr :'',
					 lxmc :'',
					 noticesourcemc :'',
					 bjmc :'',
					 xh :'',
 					 id:''
 				},
         comboxlist:[]//下拉框 动态的
 			}
 		},
 		created() {
  		 this.form.id = this.params.row.id;
          this.loadinfo();
          this.getcomlist()
 		},
 		methods: {
      getcomlist(){
         var logininfo = JSON.parse(localStorage.logininfo) ;
         this.axios.get(this.$store.state.api + 'bj/getbj',{
             params:{
                 yhid:logininfo.id+'',
                 xxid:logininfo.xxid+''
             }
         }).then( res => {
            let data = res.data.data;
               let list = data.list;
               this.comboxlist = list;
         }).catch( res => {
         })
       } ,
 			loadinfo(){
 				 var logininfo = JSON.parse(localStorage.logininfo) ;
 				 this.axios.get(this.$store.state.api+'notice/info',{
 						 params:{
 							 xxid:logininfo.xxid,
 							 yhid:logininfo.id,
 							 id:this.form.id
 						 }
 					}).then( res =>  {
 							this.form=res.data.data
              console.log(this.form)
              console.log(1111)
 					 }).catch(res => {
 						 this.$message.warning("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
 					 })
 			},
 			 submit() {
 				//检测
 				this.$store.state.loading = true;
 				/*if(!this.form.id) {
 					this.$message.warning('请填写分类');
 					this.$store.state.loading = false;
 					return;
 				}*/
 				//装载数据
//      alert(this.form.lxmc)
//      alert(this.form.noticesourcemc)
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
 						id: this.form.id+'',
 						bt: this.form.bt+'',
 						nr: this.form.nr+'',
 						lx: this.form.lxmc+'',
 						noticesource: this.form.noticesourcemc+'',
 						bjid: this.form.bjmc+'',
 						xh: this.form.xh+'',
 						yhid: logininfo.id+'',
 						xxid: logininfo.xxid+''
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'notice/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$store.state.loading = false;
 							} else {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$store.state.loading = false;
 							}
 						}).catch(res => {
 							this.$message.warning("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 .wrap {
   text-align: center;
 }
 .bt{
     position: absolute;
     width: 100%;
     height: 50px;
     margin: 0 auto;
     top: 0;
     left: 0;
     background: #50BFFF;
     color:white;
     text-align:left;
     line-height: 50px;
     font-size: 17px;
     padding-left: 15px;
   }

 .form {
   text-align: left;
   margin-top: 20px;
 }
  .input {
           width: 300px;
           display: inline-block;
       }

 .select-block {
   display: block;
   width: 85%;
 }

 .submit {
   width: 120px;
 }
 </style>
